using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter10
{
	/// <summary>
	/// Example10: Rotating Rod
	/// A uniform rod of length L and mass M is attached at one 
	/// end to a frictionless pivot and is free to rotate about 
	/// the pivot in the vertical plane, as in Figure 10.18.
	/// The rod is released from rest in the horizontal position. 
	/// What is the initial angular acceleration of the rod and 
	/// the initial linear acceleration of its right end?
	/// \alpha = 3g/(2L)
	/// a_t = 3/2*g
	/// </summary>
	public class Example10
	{
		public Example10()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.Mass M = new L.Mass();
			M.kg = 10.0;
			L.Length l = new L.Length();
			l.m = 3.0;
			L.RigidBody rod = new L.RigidBody(M);
			rod.SetRodAboutEnd(l);
			L.Position r = new L.Position();
			r.Z = l.m/2.0;
			L.Force f = new L.Force();
			f.Y = M.kg*L.Constant.AccelerationOfGravity;
			L.Torque tau = new L.Torque(r,f);
			L.AngularAcceleration alpha = new L.AngularAcceleration();
            alpha.X = tau.X/rod.RigidBodyMomentOfInertia.XX;
			result+=Convert.ToString(alpha.X)+"\r\n";	
			result+=Convert.ToString(l.m*alpha.X)+"\r\n";
		}
	}
}
